import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 模具类型信息 */
export interface Category {
  id: number // 类型id
  name?: string // 类型名称
  code: string // 类型编码
  status?: number // 状态
  description: string // 描述
  parentId?: number // 父id
  children?: Category[]
}

// 模具类型 API
export const CategoryApi = {
  // 查询所有模具类型
  getCategoryAll: async () => {
    return await request.get({ url: `/mold/category/all` })
  },

  // 查询模具类型列表
  getCategoryList: async (params) => {
    return await request.get({ url: `/mold/category/list`, params })
  },

  // 查询模具类型详情
  getCategory: async (id: number) => {
    return await request.get({ url: `/mold/category/get?id=` + id })
  },

  // 新增模具类型
  createCategory: async (data: Category) => {
    return await request.post({ url: `/mold/category/create`, data })
  },

  // 修改模具类型
  updateCategory: async (data: Category) => {
    return await request.put({ url: `/mold/category/update`, data })
  },

  // 删除模具类型
  deleteCategory: async (id: number) => {
    return await request.delete({ url: `/mold/category/delete?id=` + id })
  },

  // 导出模具类型 Excel
  exportCategory: async (params) => {
    return await request.download({ url: `/mold/category/export-excel`, params })
  },

  // 下载导入模板
  importTemplate: async () => {
    return request.download({ url: '/mold/category/get-import-template' })
  }
}
